class_name AttributeReaction
extends Node2D



enum Type
{
    NONE,
    MELT,               # 融化，fire and ice
    OVERLOAD,           # 超载，fire and thunder
    SUPERCONDUCTION,    # 超导, ice and thunder
    BROKEN,             # 破碎，ice and normal
}


@export var type: Type
@export var is_stop_anomaly: bool

# func _ready() -> void:
#     _start()
#     _effect()


## 用于初始化相关数据
func _start() -> void:
    pass


## 实现效果
func effect(_info: DamageInfo) -> void:
    pass


static func get_type(type_: AnomalyState.Type, attr: DamageInfo.DamageAttribute) -> Type:
    if (type_ == AnomalyState.Type.COMBUSTION and attr == DamageInfo.DamageAttribute.ICE) or \
        (type_ == AnomalyState.Type.FREEZE and attr == DamageInfo.DamageAttribute.FIRE):
        return Type.MELT
    
    if (type_ == AnomalyState.Type.COMBUSTION and attr == DamageInfo.DamageAttribute.THUNDER) or \
        (type_ == AnomalyState.Type.PALSY and attr == DamageInfo.DamageAttribute.FIRE):
        return Type.OVERLOAD
    
    if (type_ == AnomalyState.Type.FREEZE and attr == DamageInfo.DamageAttribute.THUNDER) or \
        (type_ == AnomalyState.Type.PALSY and attr == DamageInfo.DamageAttribute.ICE):
        return Type.SUPERCONDUCTION
    
    if (type_ == AnomalyState.Type.FREEZE and attr == DamageInfo.DamageAttribute.NORMAL):
        return Type.BROKEN

    return Type.NONE


static func get_type_str(type_: Type) -> String:
    match type_:
        Type.MELT: return "融化"
        Type.OVERLOAD: return "超载"
        Type.SUPERCONDUCTION: return "超导"
        Type.BROKEN: return "破碎"
        _: return "无"


func get_type_text() -> String:
    return get_type_str(type)


func get_reaction_color() -> Color:
    return get_color(type)


static func get_color(type_: Type) -> Color:
    match type_:
        Type.MELT: return Color8(255, 106, 0)
        Type.OVERLOAD: return Color.RED
        Type.SUPERCONDUCTION: return Color.YELLOW
        Type.BROKEN: return Color8(200, 255, 255)
    return Color.WHITE